package java8;

import java.time.Instant;
import java.time.LocalDateTime;

/**
 * @ProjectName random_code
 * @PackageName PACKAGE_NAME
 * @ClassName Java8Date
 * @Description:
 * @author: Administrator
 * @Date: 2019/6/26 15:31
 * @Version 1.0
 */
public class Java8Date {

    public static void main(String[] args){
        Java8Date java8Date = new Java8Date();
        java8Date.localDateTimeInstance();
    }

    public void localDateTimeInstance(){
        LocalDateTime localDateTime = LocalDateTime.now();
        LocalDateTime future = localDateTime.plusMinutes(20);
        Boolean isAfter = localDateTime.isAfter(future);
        Boolean isBefor = localDateTime.isBefore(future);
        System.out.println("****************LocalDateTime当前时间***********************");
        System.out.println(localDateTime);
        System.out.println("****************LocalDateTime二十分钟后的时间****************");
        System.out.println(future);
        System.out.println("****************after两者作比较****************");
        System.out.println("AFTER"+isAfter);
        System.out.println("BEFOR"+isBefor);
    }

    public void instantExample(){
        Instant currentInstant = Instant.now();
        Instant nextInstant = currentInstant.plusSeconds(1200);
        System.out.println("****************Instant当前时间***********************");
        System.out.println(currentInstant);
        System.out.println("****************Instant二十分钟后的时间****************");
        System.out.println(nextInstant);
    }
}
